//
//  SortHelp.m
//  NEWS_W_Y_S
//
//  Created by lanou3g on 15/10/16.
//  Copyright © 2015年 lanou3g.jake. All rights reserved.
//

#import "SortHelp.h"
#import "UrlConnection.h"
#import "RadioSortModel.h"

static SortHelp *sortHelp = nil;


@implementation SortHelp

+(SortHelp *)shareSortHelp{
    static dispatch_once_t onceToken;
    dispatch_once(&onceToken, ^{
        if (sortHelp == nil) {
            sortHelp = [[SortHelp alloc] init];
        }
    });
    return sortHelp;
    
}


-(void)requestWithUrl:(NSString *)url block:(void (^)(NSMutableArray *))block
{
    dispatch_async(dispatch_get_global_queue(0, 0), ^{
       
        [UrlConnection startConnection:url parmaters:nil connetionBlock:^(id responseObject) {
            self.dataArray = [NSMutableArray array];
            
            if (responseObject) {
                NSArray *array = responseObject[@"tList"];
                for (NSDictionary *dic in array) {
                    RadioSortModel *model = [[RadioSortModel alloc] init];
                    [model setValuesForKeysWithDictionary:dic];
                    [self.dataArray addObject:model];
                }
                
            }
            
            dispatch_async(dispatch_get_main_queue(), ^{
                block(_dataArray);
            });
            
        }];
     
    });
}






@end
